package freespiritsocial.io.user.viewmodel

import freespiritsocial.io.user.network.apiService
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.callback.databind.StringObservableField
import me.hgj.jetpackmvvm.ext.requestNoCheck

class ForgetViewModel: BaseViewModel() {
    val phoneNumber = StringObservableField()
    val countryCode = StringObservableField("+44")

    fun checkMobile(success: () -> Unit) {
        requestNoCheck({
            apiService.checkMobile(countryCode.get(),phoneNumber.get().replace(" ",""))
        },{
            when {
                it.isSucces() -> toast.postValue("This account does not exist")
                it.code == 30004 -> success.invoke()
                else -> toast.postValue(it.message)
            }
        },isShowDialog = true)
    }
}
